var stream = require('stream')
var http = require('http')
var fs = require('fs')
var server = http.createServer((req, res) => {
  if (req.url === '/') {
    var fileList = fs.readdirSync('../../')
    res.end(fileList.toString())

  }
  else {
    var path = `../..${req.url}`
    fs.stat(path, (err, data) => {
      if (err) {
        throw err
      } else {
        fs.createReadStream(path).pipe(res)
      }
    })
  }
}).listen(8080)